<?php
require('./roots.php');
require($root_path.'include/inc_environment_global.php');

//Importacion y creacion de instancia de la clase queries_ajax_usutriaje
$filename = $root_path."db/interconsulta/queries_ajax_usutriaje.php";
require_once($filename);
$query_ajax_usutriaje = new Queries_ajax_usutriaje();


global $db;
extract($_POST);
$val=substr_replace($val,'',(strlen($val))-1);

//$sql = "SELECT login_id, name from care_users WHERE permission='_a_2_intertriajewrite' AND login_id NOT IN (SELECT login_id FROM care_interconsulta_grupo_triaje WHERE nombre='" . $val . "')";
$sql = $query_ajax_usutriaje->select_care_users($val);
echo $sql;

$i = 0;
if($result=$db->Execute($sql)){
    if ($result->RecordCount())
    {
        while($temp=$result->FetchRow())
        {
            $acum .= 'option0 = new Option("' . $temp['name'] . '", "' . $temp['login_id'] . '");';
            $acum .= 'mywin.document.'.$formname.'.noasig.options[' . $i . '] = option0;';
            $i++;
        }
    }
}

//$sql = "SELECT login_id, name from care_users WHERE login_id IN (SELECT login_id FROM care_interconsulta_grupo_triaje WHERE nombre='" . $val . "') ";
$sql = $query_ajax_usutriaje->select_care_users_triaje($val);
$i = 0;
if($result=$db->Execute($sql)){
    while($temp=$result->FetchRow())
    {
        $acum .= 'option0 = new Option("' . $temp['name'] . '", "' . $temp['login_id'] . '");';
        $acum .= 'mywin.document.'.$formname.'.asig.options[' . $i . '] = option0;';
        $i++;
    }
}
print_r($acum);
?>
